﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using EasyLucky.Message.Messages;
using EasyLucky.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace EasyLucky
{
    public class MainWindowViewModel:ObservableObject
    {
        private Visibility indexVisibility;

        public Visibility IndexVisibility
        {
            get { return indexVisibility; }
            set { SetProperty(ref indexVisibility , value); }
        }

        private Visibility luckyVisibility;

        public Visibility LuckyVisibility
        {
            get { return luckyVisibility; }
            set { SetProperty(ref luckyVisibility, value); }
        }

        private Visibility endVisibility;

        public Visibility EndVisibility
        {
            get { return endVisibility; }
            set { SetProperty(ref endVisibility, value); }
        }


        public MainWindowViewModel()
        {
            this.IndexVisibility = Visibility.Visible;
            this.LuckyVisibility = Visibility.Collapsed;
            this.EndVisibility = Visibility.Collapsed;
            WeakReferenceMessenger.Default.Register<StateChangedMessage>(this, StateChangeHandler);
        }

        private void StateChangeHandler(object sender,StateChangedMessage message)
        {
            var v = message.Value;
            if (v==1)
            {
                //下一页
                this.IndexVisibility = Visibility.Collapsed;
                this.LuckyVisibility = Visibility.Visible;
                this.EndVisibility= Visibility.Collapsed;
            }else if (v == 2)
            {
                this.IndexVisibility = Visibility.Collapsed;
                this.LuckyVisibility = Visibility.Collapsed;
                this.EndVisibility = Visibility.Visible;
            }
            else
            {
                //上一页
                this.IndexVisibility = Visibility.Visible;
                this.LuckyVisibility = Visibility.Collapsed;
                this.EndVisibility = Visibility.Collapsed;
            }
        }
    }
}
